import axios from "axios";
const request = axios.create({
    timeout: 5000
})
request.interceptors.request.use(config => {
    // if (config.url.includes("/addCowry")){
    //     config.headers['Context-Type'] = 'multipart/form-data'
    //     return config ;
    // }
    config.headers['Context-Type'] = 'application/json;charset=utf-8'
    return config;
},error => {
    return Promise.reject(error);
})
request.interceptors.response.use(response =>{
    let res = response.data
    if (response.config.responseType === 'blob'){
        return res;
    }
    if (typeof res === 'String'){
        res = res ? JSON.parse(res) : res;
    }
    return res;
})

export default request